home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / Example Scripts / MacWriteII.vu < prev    next >
Encoding:
Text File  |  1998-06-04  |  3.6 KB  |  118 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:        MacWriteII.vu
  3. #
  4. #    Contains:    Sample demo working with MacWrite II 1.1
  5. #
  6. #    Written by:    David Gaxiola
  7. #
  8. #    Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  9. #
  10. #    Change History (most recent first):
  11. #
  12. #                3/4/96        JC      Modified EditTheText() task to do an exact match on
  13. #                                    [window o:1 s:dialog]!
  14. #                 7/2/92        DGG        Created.
  15. #
  16. #    To Do:
  17. #
  18.  
  19. Libraries "UtilityTasks.vulib","StandardDialogs.vulib","DataUtils.vulib";
  20.  
  21. (************************************************************************************
  22. * Task GenerateSomeText()
  23. *    This task will output a message to the currently active window.  One may
  24. *    note that this is a modified form of the GenerateSomeText found in the
  25. *    AppleLink.vu script.
  26. ************************************************************************************)
  27. task GenerateSomeText()
  28. begin
  29.     global gTheCatcher;
  30.     global gTheListOfStrings;
  31.     
  32.     numberOfFonts := card collect [menuItem m:"Font"];
  33.     
  34.     type k:{gTheCatcher, returnKey};
  35.     UseKeyboardEquivalent("a");
  36.     UseKeyboardEquivalent("x");
  37.     
  38.     for each singleString in gTheListOfStrings
  39.     begin
  40.         type k:{singleString, returnKey};
  41.         UseKeyboardEquivalent("t");
  42.         select [menuItem o:random(1,9) m:"Style"];
  43.         select [menuItem o:random(1,numberOfFonts) m:"Font"];
  44.     end;
  45.     
  46.     for counter := 1 to 5
  47.         UseKeyboardEquivalent("v");
  48. end;
  49.  
  50. (************************************************************************************
  51. * Task EditTheText()
  52. *    This task will perform a search and replace on the the text in the 
  53. *    currently active window.  Note that errors in typing may cause this task
  54. *    to fail.
  55. ************************************************************************************)
  56. task EditTheText(stringToSearch := "", stringToReplace := "")
  57. begin
  58.     match [window o:1 r:?docPosition];
  59.     select [menuItem t:/Find∂/Change≈/ m:"Edit"];
  60.     drag [window o:1 t:"Find/Change"] a:{docPosition[1],docPosition[2]};
  61.     type k:{stringToSearch, tabKey, stringToReplace};
  62.     select [button t:"Find Next" w:"Find/Change"];
  63.     wait(2);
  64.     if match [window o:1 s:dialog]!
  65.     begin
  66.         select [button t:"OK" w:[window o:1]];
  67.         println "### Find command failed!";
  68.         close [window t:"Find/Change"];
  69.     end;
  70.     else
  71.     begin
  72.         select [button t:"Change" w:"Find/Change"];
  73.         close [window t:"Find/Change"];
  74.     end;
  75. end;
  76.  
  77. (************************************************************************************
  78. * Task MacWriteIIMain()
  79. *    This is the script body which will control the testing of MacWrite II.
  80. ************************************************************************************)
  81. script MacWriteIIMain()
  82. begin
  83.     # Define variables.
  84.     global gTheCatcher := "and again";
  85.     global gTheListOfStrings := 
  86.     {     
  87.         "Welcome to Virtual User 2.0!",
  88.         "We here at Apple are really excited that you chose our product.",
  89.         "It represents a lot of time spent on research and development of",
  90.         "the next step in Automated Testing.",
  91.         "We think you'll find it fun and productive to use,",
  92.         "and hopefully you'll come back to VU again and again."
  93.     };
  94.     
  95.     theSearchString := gTheListOfStrings[4];
  96.     theReplaceString := "this application, which we think is the best in Automated Testing.";
  97.     savedName := "VU MacWriteII Demo";
  98.  
  99.     # Create the new document.
  100.     select [menuItem t:"New" m:"File"];
  101.     GenerateSomeText();
  102.     
  103.     # Save and close it.
  104.     DoSaveAs(savedName);
  105.     close [window t:savedName];
  106.     
  107.     # Reopen the document and edit it.
  108.     select [menuItem t:/Open≈/ m:"File"];
  109.     SelectFromStandardFile({ConcatStrings({savedName[1],savedName[2],savedName[3]})}, 
  110.                             0);
  111.     EditTheText(theSearchString, theReplaceString);
  112.  
  113.     # Save it again.
  114.     DoSaveAs(savedName);
  115.  
  116.     # Close window.
  117.     close [window t:savedName o:1];
  118. end;